﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MoPhongThuatToan
{
    public partial class Form1 : Form
    {
        Graphics G;
        VeDoThi VeDT;
        Bitmap bm;

        public Form1()
        {
            InitializeComponent();
            bm = new Bitmap(this.panel1.Width, this.panel1.Height);
            G = panel1.CreateGraphics();
        }
        
        private void bt_MoMaTran_Click(object sender, EventArgs e)
        {
            
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Open file ...";
            ofd.Filter = "Text|*.txt|All File()|*.*";
            ofd.FilterIndex = 2;
            ofd.DereferenceLinks = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                MaTran.Docfile(ofd.FileName);
                VeDT = new VeDoThi();
                G.Clear(Color.White);
                VeDT.vedothi(MaTran.a, MaTran.spt, G);
                
            }
            
        }

        private void bt_MoDanhSach_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Title = "Open file ...";
            ofd.Filter = "Text|*.txt|All File()|*.*";
            ofd.FilterIndex = 2;
            ofd.DereferenceLinks = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                MaTran.Docfile2(ofd.FileName);
                VeDT = new VeDoThi();
                G.Clear(Color.White);
                VeDT.vedothi(MaTran.a, MaTran.spt, G);

            }
        }

        private void bt_LuuMaTran_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "Save file...";
            sfd.Filter = "Text|*.txt|All File()|*.*";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                MaTran.Ghifile(sfd.FileName);
            }
        }

        private void bt_PhatSinhMaTran_Click(object sender, EventArgs e)
        {
            NhapDinhvaCanh DC = new NhapDinhvaCanh();
            DC.ShowDialog();
            DC.Close();
            MaTran.PhatSinh(DC.dinh, DC.canh);
            VeDT = new VeDoThi();
            G.Clear(Color.White);
            VeDT.vedothi(MaTran.a, MaTran.spt, G);
        }


        private void cmdPrim_Click(object sender, EventArgs e)
        {


        }

        private void cmdTPLT_Click(object sender, EventArgs e)
        {
            tb_KetQua.Clear();
            TPLT lt = new TPLT();
            tb_KetQua.Text = lt.FindConnected();
        }

        


    }
}
